/**
 * 
 */
package com.et114.modules.products.proservices;

import java.util.List;

import com.et114.core.services.impl.BaseServicesImpl;
import com.et114.modules.products.commons.Const;
import com.et114.modules.products.vo.IPro;
import com.et114.modules.system.dictionary.DictionaryCache;
import com.et114.modules.system.dictionary.vo.BizOption;

/*
 * @author guanhw
 */
public class ProServiceServiceImpl extends BaseServicesImpl {
	
	private ProServiceDao proServiceDao ;

	public void setProServiceDao ( ProServiceDao proServiceDao ) {
		this.proServiceDao = proServiceDao;
	} 
	
	public List< ProService > getProServices( ProService vo ) throws Exception {
		return proServiceDao.getProServices ( vo ) ; 
	}
	
	public List< ProService > getProserviceTypeByPro( ProService vo ) throws Exception { 
		return proServiceDao.getProserviceTypeByPro ( vo ) ; 
	}
	
	
	public ProService getProServiceById( Long id ) throws Exception {
		return proServiceDao.getProServiceById ( id ) ; 
	}
	
	@ SuppressWarnings ( "unchecked" )
	public ProService getProServiceRelById( Long id , String COUNTRY ) throws Exception { 
		ProService ps = proServiceDao.getProServiceById ( id );
		if ( ps == null )
			return null;
		List < BizOption > bssOps = DictionaryCache.getInstance ( )
				.listBizOptions ( Const.DIC_B_PRO_SERVICE_PLAN_KEY , false ,
						COUNTRY );
		for ( BizOption bo : bssOps ) {
			if ( bo.getOptionValue ( ).equals ( ps.getProServiceTypeId ( ) ) ) {
				ps.setProServiceType ( new ProServiceType ( ps
						.getProServiceTypeId ( ) , bo.getOptionName ( ) , bo
						.getOptionName ( ) ) );
				break;
			}
		}
		return ps;
	}
	
	public Long saveProService( ProService vo ) throws Exception {
		return proServiceDao.saveProService ( vo ) ; 
	}
	
	public void updateProService( ProService vo ) throws Exception {
		proServiceDao.updateProService ( vo ) ; 
	}
	
	public void removceProService( Long id ) throws Exception {
		proServiceDao.removceProService ( id ) ;
	}	
	
	public void removeProserviceByPro( ProService vo ) throws Exception { 
		proServiceDao.removeProserviceByPro ( vo ) ;
	}
	
	public Long countProService( ProService vo ) throws Exception {
		return proServiceDao.countProService ( vo ) ; 
	}
	
	public long getProServicesByProIdAProType( IPro pro )throws Exception { 
		ProService psvo = new ProService( ) ; 
		psvo.setProId ( pro.getProId ( ) ) ; 
		psvo.setProType ( pro.getProType ( )  ) ; 
		return countProService( psvo ) ; 
	}
	
	public List< ProService > getProservice4View( ProService vo ) throws Exception {
		return proServiceDao.getProservice4View ( vo ) ;
	}
}
